package cn.funeralobjects.dictms.web.api;

import cn.funeralobjects.common.web.api.CommonModifyRestApi;
import cn.funeralobjects.common.web.api.RestCodeApi;
import cn.funeralobjects.common.web.api.RestEnableApi;
import cn.funeralobjects.common.web.api.RestEntityApi;
import cn.funeralobjects.dictms.web.model.MDictValue;
import cn.funeralobjects.dictms.web.model.VDictValue;
import org.springframework.data.domain.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * @author FuneralObjects
 * Create date: 2020/6/5 10:10 AM
 */
public interface DictValueApi extends
        CommonModifyRestApi<VDictValue, MDictValue, Integer>,
        RestEntityApi<VDictValue, Integer>,
        RestCodeApi<VDictValue, Integer>,
        RestEnableApi<VDictValue, Integer> {

    @GetMapping("/dict-{dictId}/all")
    Mono<List<VDictValue>> findAllByDictId(@PathVariable Integer dictId,
                                           @RequestParam(value = "value-like", required = false) String valueLike);

    @GetMapping("/dict-{dictId}/page/{num}-{size}")
    Mono<Page<VDictValue>> findPageByDictId(@PathVariable Integer dictId,
                                            @PathVariable Integer num,
                                            @PathVariable Integer size,
                                            @RequestParam(value = "value-like", required = false) String valueLike);

    @GetMapping("/dict-{dictId}/{id}")
    Mono<VDictValue> findByDictIdAndId(@PathVariable Integer dictId,
                                       @PathVariable Integer id);

    @PostMapping("/dict-{dictId}")
    Mono<VDictValue> addByDictId(@PathVariable Integer dictId,
                                 @Validated @RequestBody MDictValue dictValue);

    @PutMapping("/dict-{dictId}/{id}")
    Mono<Void> updateByDictId(@PathVariable Integer dictId,
                              @PathVariable Integer id,
                              @Validated @RequestBody MDictValue dictValue);
}
